<template>
  <div class="dashboard-container">
    <div class="app-container">
      <el-card>
        <tree-tools :tree-node="company"></tree-tools>
        <el-tree :data="departs" :props="defaultProps">
          <!-- el-tree里的内容  插槽会循环多次 slot-scope里有两个参数 node和data data表示当前节点传入的参数  -->
          <tree-tools slot-scope="{ data }" :root-node="true" :tree-node="data"></tree-tools>
        </el-tree>
      </el-card>
    </div>
  </div>
</template>

<script>
import treeTools from './components/tree-tool'
import { getDepartments } from '@/api/departments'
export default {
  components: {
    treeTools
  },
  data() {
    return {
      company: { name: '江苏传智播客教育科技股份有限公司', manager: '负责人' },
      departs: [{ name: '总裁办', manager: '曹操', children: [{ name: '董事会', manager: '曹丕' }] },
        { name: '行政部', manager: '刘备' },
        { name: '人事部', manager: '孙权' }],
      defaultProps: {
        label: 'name' // 表示 从这个属性显示内容
      }
    }
  },
  created() {
    this.getDepartments()
  },
  methods: {
    async getDepartments() {
      var res = await getDepartments()
      console.log(res)
    }
  }
}
</script>

<style>
.el-card {
  padding: 20px  140px;
  font-size:14px;
}
.el-row {
  padding:5px 0;
}
</style>
